package cn.echo.ecc.fallback;

import cn.echo.ecc.doc.CourseDoc;
import cn.echo.ecc.enums.GlobalExceptionCode;
import cn.echo.ecc.feign.CourseESService;
import cn.echo.ecc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseESServiceFallbackFactory implements FallbackFactory<CourseESService> {
    @Override
    public CourseESService create(Throwable throwable) {
        return new CourseESService() {
            @Override
            public JSONResult saveCourse(CourseDoc courseDoc) {
                return JSONResult.error(GlobalExceptionCode.FAIL);
            }

            @Override
            public JSONResult deleteCourse(Long id) {
                return JSONResult.error(GlobalExceptionCode.FAIL);
            }
        };
    }
}
